#ifndef FIREWORK_H
#define FIREWORK_H
#include <QVector3D>
#include <vector>

using namespace std;

#define M_PI    3.14159265358979323846264338327950288

class firework
{
public:
    firework();
    firework(QVector3D pos, float t, float rlife, float plife, int explc);

    void update(float dt);
    void explode() ;
    void del_sphere(int i);
    float noise(float scale);
    QVector3D sample_vel();
    void generate_color();

    QVector3D position;
    int stage; // 0 for launch, 1 for explosion
    float delay; // delay before the first launch

    vector<QVector3D> sphere_loc; // sphere for larger particles
    vector<QVector3D> sphere_vel; // velocity of the spheres
    vector<QVector3D> sphere_col; // color of the spheres

    vector<float> sphere_life; // life of the spheres
    vector<float> sphere_life_ini; // initial life of the spheres (only used in the explosion stage)

private:
    float g = -9.8f;

    float interval; // time interval between two launches
    float timer;

    int expl_count; // number of particles generated in explosion
    float r_life; // rocket life
    float p_life; // particle life

    int color_type;
};

#endif // FIREWORK_H
